package com.atguigu.crowd.service.impl;

import com.atguigu.crowd.entity.Admin;
import com.atguigu.crowd.entity.Member;
import com.atguigu.crowd.mapper.AuthMapper;
import com.atguigu.crowd.mapper.MemberMapper;
import com.atguigu.crowd.service.api.AuthMemberService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuthMemberServiceImpl implements AuthMemberService {

    @Autowired
    private MemberMapper memberMapper;


    //获取用户身份审核页面 数据
    @Override
    public PageInfo<Member> getAuthMemberPageInfo(String keyword, Integer pageNum, Integer pageSize) {
        //1.调用PageHelper的静态方法开启分页功能
        //体现了PageHelper的非侵入式设计 原本要做的查询不必要做任何修改
        PageHelper.startPage(pageNum,pageSize);

        //2.执行查询
        List<Member> list = memberMapper.selectMemberByKeyword(keyword);

        System.out.println("查询到的list: "+list.toString());
        //3.封装到PageInfo对象中
        return new PageInfo<>(list);
    }


    //修改Member的authstatus
    @Override
    public void updateMemberAuthstatusPass(Integer memberId) {
        memberMapper.updateAuthstatusPass(memberId);
    }

    //修改Member的authstatus
    @Override
    public void updateMemberAuthstatusNotPass(Integer memberId) {
        memberMapper.updateAuthstatusNotPass(memberId);
    }
}
